<template>
	<view class="index" :style="{'height':windowHeight}">
		<clothes></clothes>
		<view class="binding">
			<view class="binding-li">
				<view class="li-txt">设备智能锁网开关设置</view>
				<view>
					<switch style="transform:scale(0.8)" :checked="lockNetwork" @change="switch1Change" />
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		components: {},
		data() {
			return {
				lockNetwork:true,	//设备智能锁网开关设置
			}
		},
		onLoad() {
			this.GaoDu() //判断手机高度
		},
		onShow() {

		},
		methods: {
			switch1Change: function(e) {
				this.lockNetwork = e.detail.value
				console.log('switch1 发生 change 事件，携带值为', e.detail.value)
				
				this.ChangClick()
			},
			ChangClick() {
				// jhLockNetwork
				const value = uni.getStorageSync('iponeInfo');
				this.$REQ(this.$api.jhLockNetwork, {
					sn: value.deviceNo,
					lockNetwork: this.lockNetwork
				}, 'POST').then(res => {
					console.log(res)
					uni.showToast({
						duration: 1000,
						title: res.data.msg,
						icon: 'none',
					})
				}).catch(err => {
					console.log(err)
					uni.showToast({
						duration: 1000,
						title: err.data.msg,
						icon: 'none',
					})
				})
			},
			// 判断手机高度
			GaoDu() {
				console.log('12356')
				// 判断手机页面的高度
				uni.getSystemInfo({

					success: (res) => {
						this.windowHeight = res.windowHeight + "px";
					}
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.binding-li {
		display: flex;
		flex-wrap: nowrap;
		justify-content: space-between;
		border-bottom: 1rpx solid #eee;
		background: #fff;
		padding: 25rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
	}

	.binding {
		padding: 25rpx;
	}

	.li-txt {
		font-size: 28rpx;
		line-height: 60rpx;
	}

	.li-icon {
		width: 35rpx;
		height: 35rpx;
	}

	image {
		width: 100%;
		height: 100%;
	}
</style>